import Vue from 'vue'

export function triggerNativeEvent(el, eventName) {
  if (document.createElement) {
    return function(el, eventName) {
      var event = document.createEvent('HTMLEvents')
      event.initEvent(event, true, false)
      el.dispatchEvent(event)
    }
  } else {
    return function(el, eventName) {
      el.fireEvent('on' + eventName)
    }
  }
}

export const eventHub = new Vue()
